package view;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

import java.io.IOException;
import java.util.concurrent.atomic.AtomicReference;

public class DeleteFriend extends Application {
    private double yOffSet;

    @Override
    public void start(Stage primaryStage) throws IOException {
        Parent root = FXMLLoader.load(getClass().getResource("fxml/deletfriend.fxml"));
        primaryStage.setTitle("删除好友");
        primaryStage.setScene(new Scene(root, 400, 200));
        primaryStage.initStyle(StageStyle.TRANSPARENT);  //透明标题栏
        AtomicReference<Double> xOffSet = new AtomicReference<>((double) 0);
        primaryStage.initStyle(StageStyle.UNDECORATED); /**窗口拖动事件**/
        root.setOnMousePressed(event -> {
            xOffSet.set(event.getSceneX());
            yOffSet = event.getSceneY();
        });
        root.setOnMouseDragged(event -> {
            primaryStage.setX(event.getScreenX() - xOffSet.get());
            primaryStage.setY(event.getScreenY() - yOffSet);
        });
        primaryStage.show();
    }
}
